#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

class Solution1 {
public:
    int missingNumber(vector<int>& nums)
    {
        int hash[10000] = { 0 };
        for (int i = 0; i < nums.size(); i++)
        {
            hash[nums[i]]++;
        }
        for (int i = 0; i < nums.size(); i++)
        {
            if (hash[i] == 0)
                return i;
        }
        return nums.size();
    }
};

class Solution2 {
public:
    int missingNumber(vector<int>& nums)
    {
        int n = nums.size();
        int sum1 = n * (n + 1) / 2;
        int sum2 = accumulate(nums.begin(), nums.end(), 0);

        return sum1 - sum2;
    }
};

class Solution3 {
public:
    int missingNumber(vector<int>& nums)
    {
        int ret = 0;
        for (auto e : nums)
        {
            ret ^= e;
        }
        for (int i = 0; i <= nums.size(); i++)
        {
            ret ^= i;
        }
        return ret;
    }
};